package com.rr.springcloud.controller;

import com.rr.springcloud.client.PaymentFeignService;
import com.rr.springcloud.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author RR
 * @date 2021/3/27 17:13
 */
@RestController
public class OrderController {

    @Autowired
    private PaymentFeignService paymentFeignService;

    @GetMapping("/payment/get/{id}")
    public ResultVo getPayment(@PathVariable("id") Long id) {
        return paymentFeignService.getPayment(id);
    }

    //feign默认的等待时间是1秒，超过一秒的话会抛出异常
    //可以在配置文件中设置最少等待时间
    @GetMapping("/payment/feignTimeout")
    public String timeoutTest() {
        //等待三秒
        return paymentFeignService.timeoutTest();
    }

}
